<template>
    <div class="login" v-if="loginUseStore.flag">
        <div class="login-content">
            <div class="login-contentTitle">
                <span>登录</span>
                <i @click="loginUseStore.flag = false">x</i>
            </div>
            <div class="login-contentBottom">
                <div class="login-item" v-if="!loginUseStore.sqStatus">
                    <div class="login-itemLeft">
                        <img src="../../assets/images/ewmbackground.png" alt="">
                    </div>
                    <div class="login-itemRight">
                        <h3>扫码登录</h3>
                        <div class="ewm-img">
                            <img :src="loginUseStore.base_64Url">
                            <div class="ewm-sx" v-if="loginUseStore.expire">
                                <p>二维码已失效</p>
                                <a href="javascript:;" @click="loginUseStore.refresh">点击刷新</a>
                            </div>
                        </div>
                        <p>使用 <a target="_blank" href="https://music.163.com/#/download">网易云音乐APP</a> 扫码登录</p>
                    </div>
                </div>
                <div class="login-status" v-else>
                    <img src="../../assets/images/sqz.png" alt="">
                    <h3>扫描成功</h3>
                    <p>请在手机上确认登录</p>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { watch,onMounted } from 'vue';
import loginStore from '@/store/modules/login'
const loginUseStore = loginStore()
onMounted(()=>{
    if(loginUseStore.cookie!=null){
        loginUseStore.getLoginStatus(loginUseStore.cookie)
    }
    console.log(loginUseStore.cookie);
    
})
watch(() => loginUseStore.flag, () => {
    if (loginUseStore.flag) {
        loginUseStore.getRwmLogin()
    }
})
</script>

<style scoped lang="less">
.login {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;

    .login-content {
        position: relative;
        z-index: 9998;
        width: 530px;
        border-radius: 4px;
        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.8);
        border: none;
        background: #fff;

        .login-contentTitle {
            position: relative;
            margin: 0;
            padding: 0 45px 0 18px;
            height: 38px;
            line-height: 38px;
            z-index: 10;
            border-bottom: 1px solid #191919;
            border-radius: 4px 4px 0 0;
            background: #2d2d2d;
            font-weight: bold;
            font-size: 14px;
            color: #fff;

            i {
                position: absolute;
                z-index: 20;
                top: 16px;
                right: 20px;
                width: 10px;
                height: 10px;
                overflow: hidden;
                text-indent: -9999px;
                cursor: pointer;
                background-image: url(../../assets/images/iconback.png);
                background-position: 0 -95px;
            }
        }

        .login-contentBottom {
            margin: auto;
            padding: 0;
            border: 1px solid #d8d8d8;
            border-width: 0 1px 1px;
            border-radius: 0 0 4px 4px;
            background: #fff;
            width: 530px;
            height: 326px;
            background-color: #fff;
            display: flex;
            align-items: center;

            .login-item {
                width: 100%;
                display: flex;
                justify-content: center;
                align-items: center;
                height: 220px;

                .login-itemLeft {
                    width: 125px;
                    height: 220px;

                    img {
                        width: 100%;
                        height: 100%;
                    }
                }

                .login-itemRight {
                    margin-left: 25px;
                    width: 200px;
                    text-align: center;

                    h3 {
                        font-size: 18px;
                        font-weight: 500;
                        text-align: center;
                    }

                    .ewm-img {
                        position: relative;
                        width: 150px;
                        height: 150px;
                        padding: 4px;
                        margin: 13px auto;

                        img {
                            width: 100%;
                            height: 100%;
                        }

                        .ewm-sx {
                            position: absolute;
                            top: 0;
                            right: 0;
                            bottom: 0;
                            left: 0;
                            background: rgba(255, 255, 255, 0.9);

                            p {
                                margin: 45px auto 6px;
                                font-size: 12px;
                                color: rgba(0, 0, 0, 0.8);
                                font-weight: 500;
                            }

                            a {
                                display: block;
                                margin: 0 auto;
                                padding-right: 0;
                                width: 64px;
                                height: 24px;
                                line-height: 24px;
                                text-align: center;
                                border-radius: 4px;
                                background: linear-gradient(180deg, #81DD81 0%, #55A055 100%);
                                border: 1px solid #5BAF5B;
                                box-shadow: inset 0 -1px 1px 1px rgb(185 230 5.96774194%);
                                color: #fff;
                                font-size: 12px;
                            }
                        }
                    }

                    p {
                        font-size: 12px;
                        line-height: 17px;
                        color: rgba(0, 0, 0, 0.4);

                        a {
                            color: #0c73c2;
                        }
                    }
                }
            }
            .login-status{
                display: flex;
                flex-direction: column;
                align-items: center;
                width: 100%;
                height: 100%;
                padding-top: 40px;
                img{
                    width: 140px;
                    height: 140px;
                }
                h3{
                    margin-top: 12px;
                    font-size: 18px;
                    font-weight: 450;
                    line-height: 24px;
                    color: rgba(0, 0, 0, 0.8);
                }
                p{
                    margin-top: 4px;
                    font-size: 14px;
                    color: #333;
                }
            }
        }
    }
}</style>